<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="../js/jquery-3.4.1.js">
</script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

<script>

$(document).ready(function(){
    // 从cookie中获取id
    let usr = {uid:$.cookie("uid")}
    $.get("getall.action", usr, function(data){
        
        $("#car").empty();
        $("#allprice").html(data.allprice);
        data.slist.forEach((item, index) => {
            let str = `<div>${item.gname}-${item.price}</div>`
            $("#car").append(str)
        })
        $("#count").html(data.count)
        $("#page").empty()
        for (let i = 0; i < data.count / 10; i++) {

            $("#page").append(`<div><a href="javascript:void(0)" onclick="changepage(${i + 1})">${i + 1}</a></div>`)

        }
       
    }, "json")

})

function changepage(pageNo) {
    
    let usr = {uid:$.cookie("uid"), pageNo}
    $.get("getall.action", usr, function(data){
        
        $("#car").empty();
        $("#allprice").html(data.allprice);
        data.slist.forEach((item, index) => {
            let str = `<div>${item.gname}-${item.price}</div>`
            $("#car").append(str)
        })

        $("#page").empty()
        $("#count").html(data.count)
         for (let i = 0; i < data.count / 10; i++) {

            $("#page").append(`<div><a href="javascript:void(0)" onclick="changepage(${i + 1})">${i + 1}</a></div>`)

        }
       
    }, "json")
}

</script>
</head>
<body>
    <div id="car">
        
    </div>
    <hr />
    <div>总价格: <span id="allprice"></span></div>
    分页<span id="count"></span>
    <div id="page" style="display: flex;flex-direction: row; justify-content: space-between; width: 600px">

        
    </div>
</body>